package com.psbc.redislock.controller;

import com.psbc.redislock.annotation.RateLimiter;
import com.psbc.redislock.enums.LimitType;
import com.psbc.redislock.lock.db.EasyDBLock;
import com.psbc.redislock.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @Autowired
    EasyDBLock easyDBLock;

    @GetMapping("/hello")
    @RateLimiter(count = 5)
    public Object hello() {
        return "hello";
    }

    @GetMapping("/helloIp")
    @RateLimiter(count = 5, limitType = LimitType.IP)
    public Object helloIp() {
        return "hello";
    }

    @GetMapping("/hellojson")
    public Result hello1(){
        return Result.OK();
    }
}
